// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import VueRouter from 'vue-router'
import routes from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'
// import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// Vue.config.productionTip = false
Vue.use(VueRouter)
Vue.use(ElementUI)

const router = new VueRouter({
  routes // （缩写）相当于 routes: routes
})

// router.beforeEach((to, from, next) => {
//   if (to.path == '/login') {
//     sessionStorage.removeItem('username');
//   }
//   let user = sessionStorage.getItem('username');
//   if (!user && to.path != '/login') {
//     next({path: '/login'})
//   } else {
//     NProgress.start();
//     next()
//   }
// });
//
// router.afterEach(transition => {
//   NProgress.done();
// });
/* eslint-disable no-new */
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
